package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Phone    string `gorm:"type:char(11);"`
	UserName string `gorm:"type:varchar(20);"`
	Status   int    `gorm:"type:int(10);default:1;comment:1:正常;2:冻结"`
	Time     string `gorm:"type:varchar(20);"`
}

func (u *User) GetUser(phone string) error {
	return DB.Where("phone = ?", phone).Limit(1).Find(&u).Error
}
func (u *User) GetUserID(userId string) error {
	return DB.Where("id = ?", userId).Limit(1).Find(&u).Error
}

func (u *User) GetUserUpdate(UserId int64, status int64) error {
	return DB.Model(&User{}).Where("id = ?", UserId).Update("status", status).Error
}
func (u *User) GetUserList() (list []*User, err error) {

	err = DB.Where("status = ?", 1).First(&list).Error
	return nil, err
}
